<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Test that video is rendered after being re-inserted into a document.</title>

        <script src=media-file.js></script>
        <script>
            if (window.testRunner)
                testRunner.waitUntilDone();

            function seeked()
            {
                // Wait for one rAF to ensure a new frame is onscreen.
                if (window.testRunner)
                    requestAnimationFrame(_ => testRunner.notifyDone());
            }

            function playing()
            {
                video.pause();
                video.currentTime = 0;
            }

            function canplaythrough()
            {
                document.body.removeChild(video);
                document.body.offsetLeft;
                document.body.appendChild(video);
                video.play();
            }

            function start()
            {
                video = document.getElementsByTagName('video')[0];
                video.src = 'content/test.ogv';
                video.addEventListener('canplaythrough', canplaythrough);
                video.addEventListener('playing', playing);
                video.addEventListener('seeked', seeked);
            }

        </script>

    </head>

    <body onload="start()">
        <video width=320 height=240 ></video>
    </body>
</html>
